﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;

/// <summary>
/// 基础UI功能
/// 生命周期顺序
/// Init > Refresh > AnimateEnter 
/// Close > AnimateExit
/// </summary>
public abstract class UIBase : MonoBehaviour
{

    /// <summary>
    /// 动画进入动画
    /// </summary>
    /// <returns></returns>
    protected virtual void AnimateEnter()
    {
        this.GetComponent<UIPopAnimate>()?.PopStart();
    }


    /// <summary>
    /// 动画离开数据
    /// </summary>
    /// <returns></returns>
    protected virtual void AnimateExit()
    {
        this.GetComponent<UIPopAnimate>()?.PopEnd();
    }

    virtual protected void Init()
    {
        //刷新一次(数据显示)
        this.Refresh();

        //播放UI进入动画
        AnimateEnter();
    }

    virtual public void Close()
    {
        //播放离开动画
        AnimateExit();
    }


    virtual public void Refresh()
    {

    }


}

public interface IUIBase
{
    // /// <summary>
    // /// 动画进入数据
    // /// </summary>
    // void AnimateEnter();

    // /// <summary>
    // /// 动画离开数据
    // /// </summary>
    // /// <returns></returns>
    // void AnimateExit();

    /// <summary>
    /// 直接初始化接口
    /// </summary>
    void Init();

    /// <summary>
    /// 关闭
    /// </summary>
    void Close();

    /// <summary>
    /// 刷新
    /// </summary>
    void Refresh();


}
